package com.example.fall_guard_band.service.ServiceImpl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.fall_guard_band.mapper.NursingHomeMapper;
import com.example.fall_guard_band.pojo.entity.NursingHome;
import com.example.fall_guard_band.pojo.vo.NursingHomeSimpleVO;
import com.example.fall_guard_band.service.NursingHomeService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class NursingHomeServiceImpl implements NursingHomeService {

    private final NursingHomeMapper nursingHomeMapper;

    @Override
    public NursingHome showALLHome() {
        return null;
    }

    @Override
    public List<NursingHomeSimpleVO> listAllHomes() {
        // 默认仅展示启用状态的养老院，如需展示全部可移除状态条件
        List<NursingHome> homes = nursingHomeMapper.selectList(new LambdaQueryWrapper<NursingHome>()
                .eq(NursingHome::getStatus, 1));
        return homes.stream().map(h -> {
            NursingHomeSimpleVO vo = new NursingHomeSimpleVO();
            vo.setId(h.getId());
            vo.setName(h.getName());
            return vo;
        }).collect(Collectors.toList());
    }
}
